﻿
$.MGJ.Demo = [];


(function () {
    var _this = $.MGJ.Demo;

    $.extend($.MGJ.Demo, {
        // 新增用户

        Dialog_AddObj: null,
        Dialog_Add: function () {

            //$my.GetPCR(0, 0);
            this.Dialog_AddObj = $.L.dialog({
                url: ACTION_URL("Add", "Demo"),
                title: "新增Demo",
                width: 800,
                height: "auto",
                buttons: {
                    "button_save": {
                        type: 'primary',
                        text: '保存',
                        click: function () {
                            $.MGJ.Demo.Ajax_AddDemo();
                        }
                    },
                    "button_cancel": {
                        type: 'default',
                        text: '取消',
                        click: 'MODALMISS'
                    }
                }
            });
        },

            Dialog_EditObj: null,
            Dialog_Edit: function () {

                //$my.GetPCR(0, 0);
                this.Dialog_EditObj = $.L.dialog({
                    url: ACTION_URL("Edit", "Demo"),
                    title: "编辑Demo",
                    width: 800,
                    height: "auto",
                    buttons: {
                        "button_save": {
                            type: 'primary',
                            text: '保存',
                            click: function () {

                                $.MGJ.Demo.Ajax_UpdDemo();
                            }
                        },
                        "button_cancel": {
                            type: 'default',
                            text: '取消',
                            click: 'MODALMISS'
                        }
                    }
                });
            }

    });
})(jQuery);


(function () {
    var _this = $.MGJ.Demo;

    $.extend($.MGJ.Demo, {
        //分页
        //查询机构
        Ajax_PageList: function (pageIndex,where) {

            $.L.ajaxHandle({
                url: ACTION_URL("PageList", "Demo"),
                data: {
                    where:where,
                    pageIndex: pageIndex,
                    pageSize: 10
                },
                success: function (response) {
                    $("#DemoTable").L_bindingDataList(response);
                }
            });
        },
        //删除
        Ajax_DelDemo: function (obj)
        {
           var id= $(obj).attr("DemoID");
            $.L.ajaxHandle({
                url: ACTION_URL("DelDemo", "Demo"),
                data: {id:id},
                success: function (response) {
                    $("#DemoTable").L_bindingDataList(response);
                }
            });
        },
        //修改
        Ajax_UpdDemo: function (id) {
            $.L.ajaxHandle({
                url: ACTION_URL("UpdDemo", "Demo")+"?id="+id,
                data: $("#form_Demo").serialize(),
                success: function (response) {
                    $("#DemoTable").L_bindingDataList(response);
                }
            });
        },
        //添加
        Ajax_AddDemo: function (id) {
            $.L.ajaxHandle({
                url: ACTION_URL("AddDemo", "Demo"),
                data: $("#form_Demo").serialize(),
                success: function (response) {
                    if (response > 0) {
                        _this.Dialog_AddObj.close();
                        $.L.msgSuccess("操作成功！");
                      _this.Ajax_PageList(1);
                    }
                    else {
                        $.L.msgSuccess("操作失败！");
                    }
                  
                }
            });
        }
    });
})(jQuery);